﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using UI.ParentForm;
using Components;
using UI.Lib;
using System.Collections;
using UI.Lib.Factory;

namespace UI.StorageManagement
{
    public partial class FrmStoTranQuery : BaseQuery
    {
        public FrmStoTranQuery(string modulecode, string action) :
            base(modulecode, action)
        {
            InitializeComponent();

            this.MaxStateFlag = true;
        }

        public override bool BeforePopWin(string name, ref string where, ref string[] others)
        {
            if (name == "outstkcode" || name == "instkcode")
            {
                //调入仓库和调出仓库不能是一样
                where = string.Format("statuscode = '1' {0} AND listid <> '{1}' ",
                        Context.GetAppKeyWhere("usercode", true),
                        this.tbSummary.GetValue(name == "outstkcode" ? "instk" : "outstk"));
            }
            else if ("productcode" == name)
            {
                where = string.Format("status ='1' {0}", Context.GetAppKeyWhere("muser", true));
            }

            return true;
        }

        protected override void DoSearch()
        {
            Hashtable where = new Hashtable();
            where["pid"] = Validation.ToString(this.tbSummary.GetValue("pid")); //控件ID
            where["startdate"] = Validation.ToDate(this.tbSummary.GetValue("startdate"), Global.MinDate); //控件ID
            where["endate"] = Validation.ToDate(this.tbSummary.GetValue("endate"), Global.MaxDate); //结束日期
            where["instk"] = Validation.ToString(this.tbSummary.GetValue("instk"));
            where["outstk"] = Validation.ToString(this.tbSummary.GetValue("outstk"));

            DataTable dt = CommonHelper.Entity.ExecFun("tranquerysource", where);

            BinderGrid(dt);
        }
    }
}
